'use strict';

module.exports = {
  up: async (queryInterface, Sequelize) => {
    const { INTEGER, STRING, DATE } = Sequelize;
    
    await queryInterface.createTable('user_shortcuts', {
      id: {
        type: INTEGER,
        primaryKey: true,
        autoIncrement: true
      },
      user_id: {
        type: INTEGER,
        allowNull: false,
        comment: '用户ID'
      },
      type: {
        type: STRING(20),
        allowNull: false,
        comment: '快捷键类型: global(全局), module(模块)'
      },
      module_id: {
        type: STRING(50),
        allowNull: true,
        comment: '模块ID'
      },
      key: {
        type: STRING(20),
        allowNull: false,
        comment: '快捷键'
      },
      action: {
        type: STRING(100),
        allowNull: false,
        comment: '操作'
      },
      description: {
        type: STRING(200),
        allowNull: true,
        comment: '描述'
      },
      created_at: {
        type: DATE,
        allowNull: false,
        defaultValue: Sequelize.NOW
      },
      updated_at: {
        type: DATE,
        allowNull: false,
        defaultValue: Sequelize.NOW
      }
    });
  },

  down: async (queryInterface, Sequelize) => {
    await queryInterface.dropTable('user_shortcuts');
  }
};